$("body").delegate("#downExcelModel","click",function(){
    var url = base+"/projectCenter/excelApi/exportTrzlExcelData/"+mention_id+"/"+project_id;
    window.open(url,"_self");
    return false;
});

var pnum=1;
var initData = function(num){
    var url = base+"/projectCenter/sjps/mentionDetailData";
    var param = {
        page_num:num,
        page_size:"6",
        mention_data_id:mention_id,
        project_id:project_id
    };
    $.ajax({
        url: url,
        data: param,
        success: function (data, textStatus, jqXHR) {
            if(data != null){
                if(data.form != null){
                    layui.use(['layer', 'form', 'element'], function(){
                        var layer = layui.layer
                            ,form = layui.form()
                        var html = data.form;
                        $("#view").html("");
                        $("#view").html("<form class='layui-form' style='float:left;'>"+html+"</form>");
                        form.render();
                        initializeFunction();
                        upload();
                    });
                }else{
                    showButton();
                    var pageCount = data.data_list.pager.pageCount;
                    var dataObj ={
                        "list":data.data_list.list,
                        "dataTool":{
                            "title":{
                            },
                            "editField":{},
                            "titleCheckbox":false,
                            "btn":[]
                        }
                    };
                    var title_list = data.title_list;
                    var title = dataObj.dataTool.title;

                    var edit = dataObj.dataTool.editField;
                    $.each(title_list,function(index,value){
                        var field_name = title_list[index].field_name;
                        var field_comment = title_list[index].field_comment;
                        if (field_name!="id"&& field_name!="project_id") {
                            title[field_name] = field_comment;
                            var editField = {};
                            editField["field"] = field_name;
                            editField["type"] = "text";
                            edit[index]=editField;
                        }
                    });
                    edit = JSON.stringify(edit);
                    head_data_list = title; //将表头作为全局表里保存以便编辑操作
                    title.operation = "操作";
                    showPageTable('view', dataObj,num,pageCount,"initData");
                }
            }
        },
        error: function () {
        }
    });

}

var showButton = function(){
    var button_html = ' <div class="btn-team">'+
        ' <button class="btn btn-default" id="downExcelModel">下载文件</button></div>';
    $(".btn-team").remove();
    $("#div_content").prepend(button_html);
}

function backup(){
    var url = base+"/projectCenter/sjps/index/"+project_id;
    $.get(url, function(result){
        // $(".layui-show").html("");
        $("#mention_data").html(result);
    });
}
$(document).ready(function(){
    initData(1);
});

